{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a7688250-15db-469c-a77d-dcc9873c8a8c",
   "metadata": {},
   "source": [
    "# Python的基本数据类型\n",
    "\n",
    "## list tuple "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cebf80f6-907e-4218-92cc-06da1b20209a",
   "metadata": {},
   "source": [
    "### 请手工写出一个包含10个数字的列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "571eb498-77b2-4bcc-b0a9-05570f436b97",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'list'>\n"
     ]
    }
   ],
   "source": [
    "a=[0,1,2,3,4,5,6,7,8,9]\n",
    "print(type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d81ad65b-6aa4-44b7-a996-59443c0a1663",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n"
     ]
    }
   ],
   "source": [
    "b=range(10)\n",
    "print(list(b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "17c8cf6d-af24-4a97-b110-333568d123a0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n",
      "6\n",
      "7\n",
      "8\n",
      "9\n"
     ]
    }
   ],
   "source": [
    "for i in [0,1,2,3,4,5,6,7,8,9]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "22d4e49c-2289-4b13-92db-5fd4a9d5f6fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n",
      "[9, 8, 7, 6, 5, 4.5, 4, 3, 2, 1, 0]\n"
     ]
    }
   ],
   "source": [
    "b=[]\n",
    "for i in range(9,-1,-1):\n",
    "    b.append(i)\n",
    "print(b)\n",
    "b.insert(5,4.5)\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "4f1ce59c-12ee-484f-bc5b-2c495117d715",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[323, 324]\n"
     ]
    }
   ],
   "source": [
    "a=list(range(1,1001))\n",
    "print(a[322:324])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56eb50ee-1b47-438d-9891-70be4619e440",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "914dd668-2227-4319-81b0-5e352b424bf0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词  APPLE\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "APPLE的中文为苹果\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词 apple \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "apple的中文为苹果\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词 苹果\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "苹果的英文为apple\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词  苹果\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "苹果的英文为apple\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词 香蕉\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "香蕉的英文为banana\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词   \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入错误\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词 vsjkvns\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "不知道\n"
     ]
    },
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入单词 END\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "程序终止\n"
     ]
    }
   ],
   "source": [
    "dict_1={'apple':'苹果','banana':'香蕉','orange':'橙子','strawberry':'草莓','grape':'葡萄','red':'红色','yellow':'黄色','black':'黑色','green':'绿色','pink':'粉色'}\n",
    "while True:\n",
    "    word_input=str(input('请输入单词')).strip()\n",
    "    if word_input.lower() in dict_1.keys():\n",
    "        chinese_1=dict_1[word_input.lower()]\n",
    "        print(word_input+\"的中文为\"+chinese_1)\n",
    "    elif word_input in dict_1.values():\n",
    "        for k,v in dict_1.items():\n",
    "            if word_input==v:\n",
    "                print(word_input+\"的英文为\"+k)\n",
    "    elif word_input.lower()=='end':\n",
    "        print('程序终止')\n",
    "        break\n",
    "    elif word_input=='':\n",
    "        print('输入错误')\n",
    "    else:\n",
    "        print('不知道')\n",
    "    \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b4b001b4-d103-485d-bc2a-c77779b5a3b8",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
